<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.knowledge.model.User" %>
<%
	User user = (User)request.getAttribute("user");
	String userId = (String)request.getAttribute("userId");	
	String loginId = (String)request.getAttribute("loginId");
%>
<script type="text/javascript">
<!--
	function toggle(show,hidden){
		document.getElementById(show).style.display = "block";
		document.getElementById(hidden).style.display = "none";
	}
	function checkFileInput(){
		var val = document.getElementById("upload").value;
		
		if(val=="")
			alert("请选择要上传的图片！");
		else{
			var form = document.getElementById("fileInput");
			form.submit();
		}
	}	
//-->
</script>
<div class="tab-content">
	<div class="right-column-holder clearfix">
		<div class="right-column feed-tab">
			<div id="proInfo">
				<%
					if(userId.equals(loginId)){
				%>
				<div class=smallBox >
					<h3>
						&nbsp;&nbsp;&nbsp;&nbsp;用户头像
					</h3>
					<div class=contentBox>
						<div style="color:red;width:100%;">${requestScope.typeError}</div>
						<form  id="fileInput"  style="display:none"
							method="post" action="upload.action"
							enctype="multipart/form-data">
							<input type="hidden" name="userId" value="<%=userId %>"/>							
							<input type="hidden" name="loginId" value="<%=loginId %>"/>
							<div class=content>
								请上传1：1比例的头像，否则图片缩放将会出现不必要的失真……
							</div>
							<div class=content>
								本头像仅支持.jpg格式的，望见谅~~~
							</div>
							<div class=content>
								<input type="file" name="upload" id="upload" size="30"/>
							</div>
							<div class=content>
								<input class="btnCss" type="button" value="上传头像"
									onclick="checkFileInput();"/>
								<input class="btnCss" type="button" value="返回"
									onclick="javascript:toggle('fileBtn','fileInput');"/>
							</div>
						</form>
						<div class=content id="fileBtn">
							<input class="btnCss" type="button" value="上传头像"
								onclick="javascript:toggle('fileInput','fileBtn');"/>
						</div>
						
					</div>
				</div>
				
				<div class=smallBox >
					<h3>
						&nbsp;&nbsp;&nbsp;&nbsp;账号信息
					</h3>
					<div class=contentBox>
						<div style="color:red;width:100%;">${requestScope.accountError}</div>
						<div class=content>
							<span>用户名</span>
							<%=user.getEmail() %>
						</div>
						
						<div class=content id="accountBtn">
							<input class="btnCss" type="button" value="修改密码"
								onclick="javascript:toggle('pwdInput','accountBtn');"/>
							<input class="btnCss" type="button" value="更改账号"
								onclick="javascript:toggle('accountInput','accountBtn');"/>
						</div>
						<form  id="pwdInput"  style="display:none"
							method="post" action="pwdModify.action">
							<input type="hidden" name="userId" value="<%=userId %>"/>							
							<input type="hidden" name="loginId" value="<%=loginId %>"/>
							<div class=content>
								<span>旧密码</span>
								<input type="password" name="oldPwd" value=""/>
							</div>
							<div class=content>
								<span>新密码</span>
								<input type="password" name="newPwd" value=""/>
							</div>
							<div class=content>
								<span>密码确认</span>
								<input type="password" name="rePwd" value=""/>
							</div>
							<div class=content>
								<input type="submit"  class="btnCss" value="修改密码"/>
								<input type="button"  class="btnCss" value="返回"
									onclick="javascript:toggle('accountBtn','pwdInput');"/>
							</div>						
						</form>
						<form  id="accountInput"  style="display:none"
							method="post" action="accountModify.action">
							<input type="hidden" name="userId" value="<%=userId %>"/>							
							<input type="hidden" name="loginId" value="<%=loginId %>"/>
							<div class=content>
								<span>新账号</span>
								<input type="text" name="email" value=""/>
							</div>	
							<div class=content>
								<span>密码</span>
								<input type="password" name="passwd" value=""/>
							</div>
							<div class=content>
								<input type="submit"  class="btnCss" value="账号更换"/>
								<input type="button"  class="btnCss" value="返回"
									onclick="javascript:toggle('accountBtn','accountInput');"/>
							</div>													
						</form>
					</div>
				</div>
				<%	} %>
				
				<div class=smallBox >
					<h3>
						&nbsp;&nbsp;&nbsp;&nbsp;个人信息
					</h3>
					<div class=contentBox>
						<div style="color:red;width:100%;">${requestScope.infoError}</div>
						<div class=content>
							<span>真实姓名</span>
							<%=user.getName() %>
						</div>
						<div class=content>
							<span>性&nbsp;&nbsp;&nbsp;&nbsp;别</span>
							<%=user.getSex() %>
						</div>
						<%
							if(userId.equals(loginId)){
						%>
						<div class=content id="infoBtn">
							<input class="btnCss" type="button" value="编辑"
								onclick="javascript:toggle('infoInput','infoBtn');"/>
						</div>
						<form  id="infoInput"  style="display:none"
							method="post" action="infoModify.action">
							<input type="hidden" name="userId" value="<%=userId %>"/>							
							<input type="hidden" name="loginId" value="<%=loginId %>"/>
							<div class=content>
								<span>真实姓名</span>
								<input type="text" name="name" value=""/>
							</div>	
							<div class=content>
								<span>性&nbsp;&nbsp;别</span>
								<input type="radio" name="gender" value="男" id="gender" />男
								&nbsp;&nbsp;&nbsp;&nbsp;
								<input type="radio" name="gender" value="女" id="gender" />女
							</div>
							<div class=content>
								<span>密码</span>
								<input type="password" name="password" value=""/>
							</div>
							<div class=content>
								<input type="submit"  class="btnCss" value="提交修改"/>
								<input type="button"  class="btnCss" value="返回"
									onclick="javascript:toggle('infoBtn','infoInput');"/>
							</div>
						</form>
						<%	} %>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
